#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct DATA
{
	char name[6];
	int votes;
};

int main(void)
{
	int n;
	char t[6];
	struct DATA men[5];
	scanf("%d",&n);
	strcpy(men[0].name,"zhang");
	strcpy(men[1].name,"wang");
	strcpy(men[2].name,"zhao");
	strcpy(men[3].name,"liu");
	strcpy(men[4].name,"miao");
	men[0].votes=0;
	men[1].votes=0;
	men[2].votes=0;
	men[3].votes=0;
	men[4].votes=0;
	for(int i=0;i<n;i++)
	{
		scanf("%s",t);
		if(strcmp(t,men[0].name)==0)
		{
			men[0].votes++;
		}
		else if(strcmp(t,men[1].name)==0)
		{
			men[1].votes++;
		}
		else if(strcmp(t,men[2].name)==0)
		{
			men[2].votes++;
		}
		else if(strcmp(t,men[3].name)==0)
		{
			men[3].votes++;
		}
		else
		{
			men[4].votes++;
		}
	}
	
	for(int i=0;i<5;i++)
	{
		printf("%s %d\n",men[i].name,men[i].votes);
	}
	
	return 0;
}

